package com.libbase.VideoMixture;

import java.util.Scanner;

public class MyMain {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        System.out.print("行：");
        int m = s.nextInt();
        System.out.print("列：");
        int n = s.nextInt();
        System.out.println("-------");
        s.close();
        int[][] a = new int[m][n];
        boolean top = true;
        boolean right = false;
        boolean buttom = false;
        boolean left = false;
        int current = 0;
        int x = 0;
        int y = 0;
        for (int i = 0; i < m * n; i++) {
            if (top) {
                if (y < n - current - 1) {
                    a[x][y] = i + 1;
                    y = y + 1;
                } else {
                    top = false;
                    right = true;
                }
            }
            if (right) {
                if (x < m - current - 1) {
                    a[x][y] = i + 1;
                    x = x + 1;
                } else {
                    right = false;
                    buttom = true;
                }
            }
            if (buttom) {
                if (y > current) {
                    a[x][y] = i + 1;
                    y = y - 1;
                } else {
                    buttom = false;
                    left = true;
                    current = current + 1;
                }
            }
            if (left) {
                if (x > current) {
                    a[x][y] = i + 1;
                    x = x - 1;
                } else {
                    left = false;
                    top = true;
                    i = i - 1;
                }
            }
        }
        for (int i = 0; i < m; i++) {
            for (int z = 0; z < n; z++) {
                if (z == n - 1) {
                    System.out.println(a[i][z]);
                } else {
                    System.out.print(a[i][z] + ",");
                }
            }

        }
    }
}
